﻿using UnityEngine;
using System.Collections;

using UnityEngine.UI;

public class TestEventTriggerListener : MonoBehaviour
{
	public Button TestButton;

	void Awake ()
	{
		TestButton.onClick.AddListener(TestOnClickHandler1);
		TestButton.onClick.AddListener(TestOnClickHandler2);
	}

	void Start ()
	{
//		EventTriggerListener.Get(this.gameObject).onClick += TestOnClickHandler1;
//		EventTriggerListener.Get(this.gameObject).onClick += TestOnClickHandler2;


	}

	public void TestOnClickHandler1()
	{
		Debug.Log("Test1");
	}
	
	public void TestOnClickHandler2()
	{
		Debug.Log("Test2");
	}

	void TestOnClickHandler1(GameObject go)
	{
		Debug.Log("Test1");
	}

	void TestOnClickHandler2(GameObject go)
	{
		Debug.Log("Test2");
	}
	
	void Update ()
	{
		if(Input.GetKeyUp(KeyCode.A))
		{
			TestButton.onClick.AddListener(TestOnClickHandler1);
		}

		if(Input.GetKeyUp(KeyCode.D))
		{
			TestButton.onClick.RemoveListener(TestOnClickHandler1);
		}

		if(Input.GetKeyUp(KeyCode.L))
		{
			TestButton.onClick.RemoveAllListeners();
		}

		if(Input.GetKeyUp(KeyCode.E))
		{
			TestButton.onClick.Invoke();
		}
	}
}
